/*************************************************
Author: byron
Date: 10/30/2012
Description:
Notes: 
*************************************************/

#ifndef __CSkill_h__
#define __CSkill_h__

#include "CSkillAffect.h"

class CSkill
{
public:
    enum SKILL_TYPE_TAG
    {
        SKILL_TYPE_NORMAL = 1,      //普通技能
        SKILL_TYPE_ACADEMIC = 2,    //学院技能
        SKILL_TYPE_MAGIC = 3,       //幻化技能
        SKILL_TYPE_STATUS = 4,      //能力技能
        SKILL_TYPE_MOUNT = 5,       //坐骑技能
    };

    CSkill()
    {
        Clear();
    }

    void Clear()
    {
        _iType = 0;
        _uiID = 0;
        _iUseAnger = 0;
        _iUseHPPercent = 0;
        _iNoAttack = 0;
        _iTargetType = 0;

        _stMainAff.Clear();
        _stMinorAff.Clear();
    }

    virtual ~CSkill(){}

    bool IsNormalSkill() const {return SKILL_TYPE_NORMAL == _iType;}
    bool IsAcademicSkill() const {return SKILL_TYPE_ACADEMIC == _iType;}
    bool IsMagicSkill() const {return SKILL_TYPE_MAGIC == _iType;}
    bool IsStatusSkill() const {return SKILL_TYPE_STATUS == _iType;}
    bool IsMountSkill() const {return SKILL_TYPE_MOUNT == _iType;}

    bool IsValidID() const {return (_uiID > 0);}
    bool IsValidType(int iType) const
    {
        return (SKILL_TYPE_NORMAL == iType ||
                SKILL_TYPE_ACADEMIC == iType ||
                SKILL_TYPE_MAGIC == iType ||
                SKILL_TYPE_STATUS == iType ||
                SKILL_TYPE_MOUNT == iType);
    }
    bool IsValidType() const
    {
        return IsValidType(_iType);
    }

    int GetType() const {return _iType;}
    unsigned int GetID() const {return _uiID;}
    int GetUseAnger() const {return _iUseAnger;}
    int GetUseHPPercent() const {return _iUseHPPercent;}
    int GetNoAttack() const {return _iNoAttack;}
    int GetTargetType() const {return _iTargetType;}
    CSkillAffect& GetMainAffect(){return _stMainAff;}
    CSkillAffect& GetMinorAffect(){return _stMinorAff;}

    void SetType(int iType){_iType = iType;}
    void SetID(unsigned int uiID){_uiID = uiID;}
    void SetUseAnger(int iUseAnger){_iUseAnger = iUseAnger;}
    void SetUseHPPercent(int iUseHPPercent){_iUseHPPercent = iUseHPPercent;}
    void SetNoAttack(int iNoAttack){_iNoAttack = iNoAttack;}
    void SetTargetType(int iVal){_iTargetType = iVal;}

    void SetMainAffect(CSkillAffect& stMainAff){_stMainAff = stMainAff;}
    void SetMinorAffect(CSkillAffect& stMinorAff){_stMinorAff = stMinorAff;}

    int GetUseHP(int iNowHP) const
    {
        return (int)(1.0 * iNowHP * _iUseHPPercent / BATTLE_RATE_SKILL_PERCENT);
    }

    bool IsMainToEnemy() const {return _stMainAff.IsToEnemy();}
    bool IsMinorToEnemy() const {return _stMinorAff.IsToEnemy();}
    
    unsigned char GetMainSkillTargetType() const
    {
        return _stMainAff.GetTargetType();
    }

    //技能是否有主目标
    bool MainSkillHasMainTargetStru() {return _stMainAff.IsTargetStruMain();}
    bool MinorSkillHasMainTargetStru() {return _stMinorAff.IsTargetStruMain();}
    
    //技能是否是群攻
    bool MainSkillHasGroupTargetStru(){return _stMainAff.IsTargetStruGroup();}
    bool MinorSkillHasGroupTargetStru(){return _stMinorAff.IsTargetStruGroup();}

    //技能是否有波及目标
    bool SkillHasMinorCentreInvo(){return _stMinorAff.IsTargetStruCentreInvo();}
    bool SkillHasMinorDistanInvo(){return _stMinorAff.IsTargetStruDistanInvo();}
    bool SkillHasMinorOneselfInvo()
    {
        return _stMinorAff.IsTargetStruOneselfInvo();
    }

    bool SkillHasMinorBackInvo(){return _stMinorAff.IsTargetStruBackInvo();}
    bool SkillHasMinorMainInvo(){return _stMinorAff.IsTargetStruMainInvo();}

    int GetMainSkillAffect(CSkillAffect& stSkillAffect);
    int GetMinorSkillAffect(CSkillAffect& stSkillAffect);

    int GetGroupSkillAffect(CSkillAffect& stGroupSkillAffect,
            bool bToMainTarget);

    void DumpSkillInfo();

private:
    int             _iType;        //技能类别 1 普通技能 2 学院技能 3 幻化技能
    unsigned int    _uiID;
    int             _iUseAnger;    //消耗怒气
    int             _iUseHPPercent;//消耗生命(百分比)
    int             _iNoAttack;    //不进行技能伤害计算
    int             _iTargetType;  //技能目标类型
    CSkillAffect _stMainAff;
    CSkillAffect _stMinorAff;
};

#endif // __CSkill_h__

